<?php
class Slog_Router
{
	public $mode;
	public $controller;
	public $action;
	public $params;

	public function init()
	{
		// Obtenemos la URI de la aplicación
		if (isset($_GET['q'])) {
			$appuri = explode('/', ltrim($_GET['q'], '/'));
		} else {
			$appuri = explode('/', ltrim(Slog::request()->getAppURI(), '/'));
		}
		
		$mode = 'public';
		
		$controller = array_shift($appuri);
		if ($controller == 'admin') {
			$mode = 'private';
			$controller = array_shift($appuri);
		}
		
		$action = array_shift($appuri);
		
		if (!$controller && !$action && Slog::config()->getString('router.default.token')) {
			list($controller, $action) = explode('/', Slog::config()->getString('router.default.token'));
		}
		if (!$controller) $controller = 'index';
		if (!$action) $action = 'index';
		
		$this->mode = $mode;
		$this->controller = $controller;
		$this->action = $action;
		$this->params = $appuri;
	}

}